﻿/************************************************************
wx
2019/10/4

*************************************************************/

using System;
using System.Diagnostics;
using UnityEngine;
using UnityEditor;
using Debug = UnityEngine.Debug;

namespace EditorTools
{
    public class ExcelToJson : MonoBehaviour
    { 
        /*
        [MenuItem("Tools/excel to json1")]
        static void ToJson1()
        {
            Process proc = new Process();
            proc.StartInfo.WorkingDirectory = $@"{Application.dataPath}\Editor\Excelcfgs\";
            proc.StartInfo.FileName = "ExcelExportTool.bat";
            proc.Start();
            proc.WaitForExit();
            Debug.Log("excel转换json完成");
        }

        [MenuItem("Tools/excel to json2")]
        static void ToJson2()
        {
            Process proc = new Process();
            proc.StartInfo.WorkingDirectory = $@"{Application.dataPath}\Editor\Excelcfgs2\";
            proc.StartInfo.FileName = "ExcelExportTool.bat";
            proc.Start();
            proc.WaitForExit();
            Debug.Log("excel转换json完成");
        }
        */
        [MenuItem("Tools/excel to json all")]
        static void ToJson()
        {
            Process proc = new Process();
            proc.StartInfo.WorkingDirectory = $@"{Application.dataPath}\Editor\ExcelToJson\";
            proc.StartInfo.FileName = "ExcelExportTool.bat";
            proc.Start();
            proc.WaitForExit(); 
            Debug.Log("excel转换json完成");
        }

        [MenuItem("Tools/excel to cs")]
        static void ExcelToCs()
        {
            Process proc = new Process();
            string targetDir = $@"{Application.dataPath}\Editor\JsonToClass\";
            proc.StartInfo.WorkingDirectory = $@"{Application.dataPath}\Editor\Excelcfgs";
            proc.StartInfo.FileName = "ExcelToCs.bat";
            proc.Start();
            proc.WaitForExit();
            Debug.Log("excel生成class完成");
        }

        [MenuItem("Tools/一键excel to json to cs")]
        static void ExcelToJsonToCs()
        {
            ToJson();
            ExcelToCs();
        }
    }
}
